<?php
/**
 * Created by PhpStorm.
 * User: stupboy
 * Date: 2018/5/9
 * Time: 10:11
 * Mail:87658989@qq.com
 */

namespace app\base\service;


class JavaGps
{
    /**
     * 获取GPS轨迹 通过服务器java服务
     * @param $driver_id
     * @param $t1
     * @param $t2
     * @param int $type
     * @return array
     */
    public function getTrack($driver_id,$t1,$t2,$type=0){
        $url       = 'http://139.224.59.63:8080/ucar/manage/drivertrack/list.do?';
        $url       = $url.'driverId='.$driver_id.'&';
        $url       = $url.'startTime='.urlencode($t1).'&';
        $url       = $url.'endTime='.urlencode($t2).'&';
        $ch        = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_HEADER,0);
        $output = curl_exec($ch);
        curl_close($ch);
        $arr    = json_decode($output,true);
        if($type==0){
            $track = $arr['data'];
        }else{
            $track = [];
            foreach ($arr['data'] as $value){
                if($value['provider']=='G'){
                    $track[] = $value;
                }
            }
        }
        return $track;
    }
}